import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/login")
public class LoginServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String ret="未知错误";
        String username=req.getParameter("username");
        String password=req.getParameter("password");
        if(null!=username && null!=password && !" ".equals(username) && !" ".equals(password)){
            if(username.equals("admin") && password.equals("admin")){
                ret="登录成功";
            }else{
                ret="姓名或密码错误，请重新输入";
            }
        }else {
            ret="非法参数";
        }
        resp.setContentType("text/html;charset=utf-8");
        resp.getWriter().println(ret);
    }
}
